<template>
  <div class="operation-buttons">
    <el-tooltip 
      v-for="action in actions" 
      :key="action.type"
      :content="action.tooltip" 
      placement="top" 
      :hide-after="1500"
    >
      <el-button 
        :type="action.type" 
        circle 
        size="small" 
        @click="handleAction(action.handler, action.params)"
        :disabled="action.disabled"
      >
        <el-icon>
          <component :is="action.icon" />
        </el-icon>
      </el-button>
    </el-tooltip>
  </div>
</template>

<script>
import { Edit, Delete, Plus, Search } from '@element-plus/icons-vue';

export default {
  name: 'TableActions',
  components: {
    Edit,
    Delete,
    Plus,
    Search
  },
  props: {
    actions: {
      type: Array,
      required: true,
      default: () => []
    }
  },
  methods: {
    handleAction(handler, params) {
      if (typeof handler === 'function') {
        if (Array.isArray(params)) {
          handler(...params);
        } else {
          handler(params);
        }
      }
    }
  }
};
</script>

<style scoped>
.operation-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
</style>